#include <stdio.h>
#include <string.h>

int main () {
    int t, i, n, mark[1100], j, a, b, leap = 0;
    char s[10];
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n); leap = 0;
        memset(mark,0,sizeof(mark));
        for (i = 0; i < n; i++) {
            scanf("%s %d %d", s, &a, &b);
            for (j = a; j < b; j++) 
                mark[j]++;
        }
        for (i = 0; i < 1000; i++) 
            if (mark[i] > 0) {
                leap = 1;
                printf("%c",mark[i]-1+'A');
            }
      //  if (leap == 1)
            printf("\n");
    }
    return 0;
}
